<template>
  <div>
    <div id="main" style="width: 1200px; height:600px;"></div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      todayMoney: 99999,
      yestdayMoney: 88887,
      todayProject: 20,
      yestdayProject: 10,
      projectData: []
    }
  },
  methods: {
    myEcharts () {
      var myChart = this.$echarts.init(document.getElementById('main')) // 基于准备好的dom，初始化echarts实例
      var option = { // 指定图表的配置项和数据
        title: {
          text: '周信息统计'
        },
        tooltip: {},
        legend: {
          data: ['订单量', '用户量', '访问量']
        },
        xAxis: {
          data: ['2020-09-01', '2020-09-02', '2020-09-03', '2020-09-04', '2020-09-05', '2020-09-06', '2020-09-07']
        },
        yAxis: {},
        series: [{
          name: '订单量',
          type: 'line',
          data: [50, 200, 3600, 30, 990, 4120, 98]
        },
        {
          name: '用户量',
          type: 'line',
          data: [1342, 2320, 3786, 7775, 3442, 3232, 5657]
        },
        {
          name: '访问量',
          type: 'line',
          data: [1900, 6902, 2531, 5657, 4334, 8378, 7238]
        }]
      }
      myChart.setOption(option) // 使用刚指定的配置项和数据显示图表。
    }
  },
  computed: {
    dataInterval () {
      return function (datetime) {
        let startTime = new Date(datetime)
        let endTime = new Date()
        let usedTime = endTime - startTime // 相差的毫秒数
        let days = Math.floor(usedTime / (24 * 3600 * 1000)) // 计算出天数
        let leavel = usedTime % (24 * 3600 * 1000) // 计算天数后剩余的时间
        let hours = Math.floor(leavel / (3600 * 1000)) // 计算剩余的小时数
        let leavel2 = leavel % (3600 * 1000) // 计算剩余小时后剩余的毫秒数
        let minutes = Math.floor(leavel2 / (60 * 1000)) // 计算剩余的分钟数
        return days + '天' + hours + '时' + minutes + '分前'
      }
    }
  },
  mounted () {
    setTimeout(() => { // 【开发】加载项目数据内容
      this.myEcharts()
    }, 1000)
  }
}
</script>
